<template>
  <div class="search">
    <f-form ref="form" :label-width='4' :action="api.company.setErpStateState" :form-key="this.formItem.companyId" handler-name="">
      <f-form-item label="是否生成凭证" name="companyErpState" :required="true" v-if="loaded" type="radio" :data="companyErpStateArray"  data-type="number" :value.sync="formItem.companyErpState"/>
      <f-form-item label="财务套账编码" name="companyCode" :required="true"   :value="formItem.companyCode"/>
      <f-form-item label="海鹰数据库实例" name="companyErpInstance" :required="true"  :value="formItem.companyErpInstance"/>
    </f-form>
  </div>
</template>

<script>

  export default {
    name: 'CompanyErp',
    props: {},
    data() {
      return {
        saving: false,
        loaded: false,
        disabled: false,
        companyErpStateArray: [],
        modalVisible: false,
        formItem: this.getFormItem()
      }
    },
    computed: {
      modalTitle: function() {
        return '企业审核-' + this.formItem.companyName
      }
    },

    methods: {
      getFormItem() {
        return {
          companyErpState: 1,
          companyCode: '',
          companyErpInstance: ''
        }
      },
      setData(data) {
        this.$refs.form.resetFields()
        if (data && data.companyId) {
          this.http.get(this, {
            url: this.api.company.get,
            params: {
              companyId: data.companyId
            },
            success: function(me, data) {
              me.loaded = true
              me.formItem = data
              me.companyErpStateArray = [{ label: '是', value: 1 }, { label: '否', value: 0 }]
            }
          })
          this.isAdd = false
        } else {
          this.formItem = this.getFormItem()
          this.loaded = true
        }
      },
      handleSubmit(callback) {
        let params = {
          companyId: this.formItem.companyId,
          companyCode: this.formItem.companyCode,
          companyErpState: this.formItem.companyErpState,
          companyErpInstance: this.formItem.companyErpInstance
        }
        this.$refs.form.handlerSubmit(params, callback)
      }
    },
    created() {

    },
    components: {}
  }
</script>

<style scoped lang="less" rel="stylesheet/less">

</style>
